/**
 * 
 */
package org.vsg.stock.basic.indicator.model;

import java.io.Serializable;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import org.vsg.stock.core.domain.StockDailyKLine;
import org.vsg.stock.core.indicator.IndicatorModel;

/**
 * @author Bill vison
 *
 */
public class StockDailyLineIndicatorModel implements IndicatorModel {
	
	private List<StockDailyKLine> coreData;
	
	public static final short READ_OPEN = 1;
	
	public static final short READ_CLOSE = 2;
	
	public static final short READ_HIGH = 3;
	
	public static final short READ_LOW = 4;
	
	public static final short READ_VOL = 5;
	
	private short readFieldMode = READ_CLOSE;
	
	private List<Number> instNumGroup = new LinkedList<Number>();
	
	public StockDailyLineIndicatorModel(List<StockDailyKLine> newData , short fieldMode) {
		coreData = newData;
		
		// --- read data handle ---
		setReadDataMode(fieldMode);
	}
	
	
	@Override
	public Serializable getIndexRef(int index) {
		// TODO Auto-generated method stub
		return null;
	}


	public void setReadDataMode(short fieldMode) {
		readFieldMode = fieldMode;
		
		StockDailyKLine stkDailyLine = null;
		for (int i = 0 ; i < coreData.size() ; i++) {
			stkDailyLine = coreData.get(i);
			
			if (readFieldMode == READ_CLOSE) {
				instNumGroup.add( stkDailyLine.getClose() );
			}
		}
		
		
	}
	

	@Override
	public Iterator<Number> iterator() {
		// TODO Auto-generated method stub
		return instNumGroup.iterator();
	}

	@Override
	public int size() {
		// TODO Auto-generated method stub
		return instNumGroup.size();
	}

	@Override
	public List<Number> getDataValues() {
		// TODO Auto-generated method stub
		return instNumGroup;
	}
	
	
	
	
}
